package kmdigit.shop.dao.persistence.ibatis;

import kmdigit.shop.dao.domain.Product;
import kmdigit.shop.dao.persistence.ProductDao;

import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.template.SqlMapDaoTemplate;

public class ProductDaoImpl extends SqlMapDaoTemplate implements ProductDao {

	public ProductDaoImpl(DaoManager daoManager) {
		super(daoManager);
	}

	@Override
	public int delete(Product product) {
		return delete(product.getProductid());
	}

	@Override
	public int delete(String productId)
	{
		return delete("Product.delete", productId);
	}
	
	@Override
	public Product getById(String productId) {
		return (Product) queryForObject("Product.getById", productId);
	}

	@Override
	public Product getById(Product product) {
		return getById(product.getProductid());
	}

	@Override
	public Integer insert(Product product) {
		return (Integer) insert("Product.insert", product);
	}

	@Override
	public int update(Product product) {
		return update("Product.update", product);
	}

}
